package org.boun.swe.ARCEONE;

import java.util.List;

import org.boun.swe.ARCEONE.Adapter.ViolationListItemAdapter;
import org.boun.swe.ARCEONE.Data.ViolationObject;
import org.boun.swe.ARCEONE.Static.Constants;
import org.boun.swe.ARCEONE.Static.PinpointType;
import org.boun.swe.ARCEONE.Utility.AsyncTaskListener;
import org.boun.swe.ARCEONE.Utility.JSONManager;
import org.boun.swe.ARCEONE.Utility.StorageManager;

import com.google.gson.reflect.TypeToken;

import android.app.ListActivity;
import android.os.Bundle;

public class ReportedViolationsActivity extends ListActivity implements AsyncTaskListener{
	private JSONManager jsonManager;
    private StorageManager storageManager;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);

        storageManager = new StorageManager(getApplicationContext());
        
	    jsonManager = new JSONManager(this);
	    jsonManager.GetJSONDataAsync(String.format(Constants.GET_REPORTED_VIOLATIONS, (String)storageManager.getStoredData(Constants.PERSISTENT_USERNAME, String.class)), 
	    		new TypeToken<List<org.boun.swe.ARCEONE.Data.ViolationObject>>(){}.getType());
	}
	
	@Override
	public void onJSONGetCompleted(Object object) {
	    List<ViolationObject> reportedViolations = (List<ViolationObject>)object;
	    ViolationListItemAdapter violationListItemAdapter = new ViolationListItemAdapter(reportedViolations, this, false);
		setListAdapter(violationListItemAdapter);
	}
	
	@Override
	public void onJSONPostCompleted() {}
	
	@Override
	public void onReverseGeocodingCompleted(String address) {}
	
	@Override
	public void onTap(int index, PinpointType pinpointType) {}
	
	@Override
	public void onUploadCompleted(String url) {}
}
